#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
void menu()
{
	printf("********************************\n");
	printf("******   1. add    2. sub  *****\n");
	printf("******   3. mul    4. div  *****\n");
	printf("******   0. exit           *****\n");
	printf("********************************\n");
}


int Add(int x, int y)
{
	return x + y;
}

int Sub(int x, int y)
{
	return x - y;
}

int Mul(int x, int y)
{
	return x * y;
}

int Div(int x, int y)
{
	return x / y;
}

int main()
{
	int (*pf[5])(int, int) = { 0, Add, Sub, Mul, Div };
	int input = 0;
	scanf("%d", &input);
	int x = 0;
	int y = 0;
	int ret = 0;

	do {
		menu();
		printf("请选择:");
		scanf("%d", &input);
		if (input >= 1 && input <= 4) {
			printf("请输入两个整数：");
			scanf("%d %d", &x, &y);
			ret = pf[input](x, y);
			printf("% d\n", ret);
		}
		else if (input == 0) {
			printf("推出计算器\n");
		}
		else {
			printf("选择错误，重新选择\n");
		}
	} while (input);
		return 0;
}